package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.JSONUtil;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Getter;
import lombok.Setter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
//因为属性里有集合,用的是额外SQL,会产生代理对象,产生handler,返回json对象时报错
@Setter@Getter
@JsonIgnoreProperties("handler")//装json对象的时候忽略 handler 属性
public class StrategyCatalog extends BaseDomain{

    private String name;

    private Strategy strategy;

    private Integer sequence;

    private Boolean state;

    private List<StrategyDetail> details = new ArrayList<>();
    public String getJson(){
        HashMap map = new HashMap<>();
        map.put("id",id);
        map.put("name",name);
        map.put("state",state);
        map.put("sequence",sequence);
        if(strategy!=null){
            map.put("strategyId",strategy.id);
            map.put("strategyTitle",strategy.getTitle());
        }
        return JSONUtil.toJSONString(map);
    }
}